﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using DevExpress.UserSkins;
using DevExpress.Skins;
using DevExpress.LookAndFeel;
using DXApplicationTangche.UC.门店下单.form;
using DXApplicationTangche.原型;
using System.Text;
using DXApplicationTangche.UC.物料管理;
using DXApplicationTangche.UC.生产计划.生产批生产;
using System.IO;
using mendian;
using DXApplicationTangche.DTO;
using DXApplicationTangche.UC.标签打印;
using DXApplicationTangche.service;
using DXApplicationTangche.UC.项目成果管理.在制品管理;
using static DXApplicationTangche.FluentMainFrame;
using DXApplicationTangche.UC.全部工序.面辅料.辅料相关;
using DXApplicationTangche.report;
using DevExpress.XtraReports.UI;
using DXApplicationTangche.UC.项目流程;
using DXApplicationTangche.UC;
using DXApplicationTangche.UC.登录;
using DXApplicationTangche.UC.金蝶;
using DXApplicationTangche.UC.Luna;
using DXApplicationTangche.UC.面料审核;
using DXApplicationTangche.UC.纳可;
using DXApplicationTangche.UC.圣同润;
using DXApplicationTangche.UC.圣同润.merchant;
using DXApplicationTangche.UC.圣同润.会销;

namespace DXApplicationTangche
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            BonusSkins.Register();
            //Application.Run(new XtraFormEXCEL());
            //DealXML.ObjectToXMLFile(new WBSItemDTO("8", "6", "辅料审核", "00.0002.0002", "ASSETES-20200929-000014"), "E:\\config辅料审核.xml", Encoding.UTF8);
            //DealXML.ObjectToXMLFile(new WBSItemDTO("7", "6", "面料审核", "00.0002.0001", "ASSETES-20200929-000013"), "E:\\config面料审核.xml", Encoding.UTF8);
            //DealXML.ObjectToXMLFile(new WBSItemDTO("17", "12", "VI质检（半成品量尺，半成品设计点检查）", "01.0005", "ASSETES-20200929-000006"), "E:\\configVI质检（半成品量尺，半成品设计点检查）.xml", Encoding.UTF8);
            //DealXML.ObjectToXMLFile(new WBSItemDTO("10", "9", "裁剪", "00.0003.0001", "ASSETES-20200929-000008"), "E:\\config裁剪.xml", Encoding.UTF8);
            //DealXML.ObjectToXMLFile(new WBSItemDTO("14", "12", "案板", "01.0002", "ASSETES-20200929-000001"), "E:\\config案板.xml", Encoding.UTF8);
            //DealXML.ObjectToXMLFile(new WBSItemDTO("15", "12", "机台", "01.0003", "ASSETES-20200929-000009"), "E:\\config机台.xml", Encoding.UTF8);
            //DealXML.ObjectToXMLFile(new WBSItemDTO("13", "12", "裁剪后接收", "01.0001", "ASSETES-20200929-000032"), "E:\\config裁剪后接收.xml", Encoding.UTF8);
            //DealXML.ObjectToXMLFile(new WBSItemDTO("16", "12", "刺绣", "01.0004", "ASSETES-20200930-000002"), "E:\\config刺绣.xml", Encoding.UTF8);
            //DealXML.ObjectToXMLFile(new WBSItemDTO("17", "12", "VI质检（半成品量尺，半成品设计点检查）", "01.0005", "ASSETES-20200929-000030"), "E:\\configVI质检（半成品量尺，半成品设计点检查）000030.xml", Encoding.UTF8);
            //DealXML.ObjectToXMLFile(new WBSItemDTO("18", "12", "钉锁", "01.0006", "ASSETES-20201012-000003"), "E:\\config钉锁.xml", Encoding.UTF8);
            //DealXML.ObjectToXMLFile(new WBSItemDTO("14", "12", "案板", "01.0002", "ASSETES-20201010-000003"), "E:\\config案板20201010-000003.xml", Encoding.UTF8);
            //DealXML.ObjectToXMLFile(new WBSItemDTO("13", "12", "裁剪后接收", "01.0001", "ASSETES-20201010-000004"), "E:\\config裁剪后接收20201010-000004.xml", Encoding.UTF8);
            //DealXML.ObjectToXMLFile(new WBSItemDTO("111", "12", "生产开始", "01.0001.01", "ASSETES-20201010-000004"), "E:\\config生产开始20201010-000004.xml", Encoding.UTF8);
            //DealXML.ObjectToXMLFile(new WBSItemDTO("111", "12", "成品一检", "01.0005.01", "ASSETES-20210625-000001"), "E:\\config成品一检20201010-000004.xml", Encoding.UTF8);
            ResourceService.synPictureResouces();
            //判断config文件，区分工控机配置
            if (Directory.Exists("C:\\Config"))
            {
                //ResourceService.synPictureResouces();
                WBSItemDTO WBSItemDTO = DealXML.XMLFlieToObject<WBSItemDTO>("C:\\Config\\config.xml", Encoding.UTF8);
                switch (WBSItemDTO.activityDescription)
                {
                    case "水洗标":
                        Application.Run(new Form水洗标());
                        break;
                    case "吊牌":
                        //Application.Run(new Form吊牌());
                        Application.Run(new FluentMainFrame().build吊牌和出库());
                        break;
                    case "包装码":
                        Application.Run(new Form包装码());
                        break;
                    /*                    case "VI质检":
                                            Application.Run(new FormVI质检("01.0005"));
                                            break;
                                        case "产成品质检":
                                            Application.Run(new FormVI质检("01.0007"));
                                            break;*/
                    default:
                        if ("生产开始".Equals(WBSItemDTO.activityDescription) || "钉锁".Equals(WBSItemDTO.activityDescription) || "手缝".Equals(WBSItemDTO.activityDescription) || "整烫".Equals(WBSItemDTO.activityDescription)
                            )
                        {
                            Application.Run(new Form生产工序(WBSItemDTO));
                        }
                        else if (WBSItemDTO.activityDescription.Contains("质检") || WBSItemDTO.activityDescription.Contains("成品一检"))
                        {
                            Application.Run(new Form质检入口(WBSItemDTO));
                        }
                        else if (WBSItemDTO.activityDescription.Contains("辅料") || WBSItemDTO.activityDescription.Equals("裁剪后接收"))
                        {
                            Application.Run(new Form辅料工序(WBSItemDTO));
                        }
                        else
                        {
                            Application.Run(new Form单步工序(WBSItemDTO));
                        }
                        break;
                }
            }
            else
            {
                //Application.Run(new Form商品信息());
                //Application.Run(new XianglebaUnDeliveryOrderLogisticsInfo());
                //Application.Run(new Form会销());

                //  1.工厂：
                Application.Run(new FluentMainFrame(Enum实体店铺.工厂));
                //  2.门店：凯丹、柏威年
                //Application.Run(new FluentDesignFormMTO());
                //  3.坚山相关：日本坚山、上海坚山
                //Form登录窗口 formLogin = new Form登录窗口();
                //if (formLogin.ShowDialog() == DialogResult.OK)
                //{
                //    if (ConstSystemUserRight.kashiyama.Equals(formLogin.systemUserRight))
                //    {
                //        //日本坚山
                //Application.Run(new FluentMainFrame(Enum实体店铺.坚山, formLogin.systemUserRightShop));
                //    }
                //    else if (ConstSystemUserRight.kashiyamaSHH.Equals(formLogin.systemUserRight))
                //    {
                //        //上海坚山
                //        Application.Run(new FluentMainFrame(Enum实体店铺.坚山上海));
                //    }
                //}
                //  4. Luna
                //Frm登陆窗口 frmLogin = new Frm登陆窗口();
                //if (frmLogin.ShowDialog() == DialogResult.OK)
                //{
                //    Application.Run(new FluentMainFrame(Enum实体店铺.Luna, Frm登陆窗口.storeAssitantDTO.name));
                //}
                //  5.  自测试使用
                //Application.Run(new Form应付管理());
                //Application.Run(new Form1());
            }
            //Application.Run(new OrderQA());
            //Application.Run(new FrmCADFiles());
            //Application.Run(new Frm上传CAD());
            //Application.Run(new Frm2());
            //var factory = new ConnectionFactory();
            //factory.HostName = "192.168.3.33";//主机名，Rabbit会拿这个IP生成一个endpoint，这个很熟悉吧，就是socket绑定的那个终结点。
            //factory.Port = 5672;
            //factory.VirtualHost = "rabbitmq";
            //factory.UserName = "rabbitmq";//默认用户名,用户可以在服务端自定义创建，有相关命令行
            //factory.Password = "rabbitmq";//默认密码


            //using (var connection = factory.CreateConnection())//连接服务器，即正在创建终结点。
            //{
            //    //创建一个通道，这个就是Rabbit自己定义的规则了，如果自己写消息队列，这个就可以开脑洞设计了
            //    //这里Rabbit的玩法就是一个通道channel下包含多个队列Queue
            //    using (var channel = connection.CreateModel())
            //    {
            //        channel.QueueDeclare("TASK_UPLOAD", false, false, false, null);//创建一个名称为kibaqueue的消息队列
            //        var properties = channel.CreateBasicProperties();
            //        properties.DeliveryMode = 1;
            //        string message = "I am Kiba518"; //传递的消息内容
            //        channel.BasicPublish("", "kibaQueue", properties, Encoding.UTF8.GetBytes(message)); //生产消息
            //        Console.WriteLine($"Send:{message}");
            //        MessageBox.Show($"Send:{message}");
            //    }
            //}
        }
    }
}
